<!DOCTYPE html>
<html>
  <head>
    <script src="./js/vue.js"></script>
  </head>
  <body>
    <h2>Vue 双向绑定</h2>
    <input type="text" id="textInput" />
    输入：<span id="textSpan"></span>
  </body>
  <script>
    let obj = {};
    let textInput = document.getElementById("textInput");
    let textSpan = document.getElementById("textSpan");

    Object.defineProperty(obj, "foo", {
      set: function (newValue) {
        textInput.value = newValue;
        textSpan.innerHTML = newValue;
      },
    });

    textInput.addEventListener("keyup", function (e) {
      obj.foo = e.target.value;
    });
  </script>
</html>
